package cn.iocoder.yudao.module.handguard.controller.app.user;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.handguard.controller.admin.banner.vo.BannerRespVO;
import cn.iocoder.yudao.module.handguard.controller.admin.statistics.vo.CountResVO;
import cn.iocoder.yudao.module.handguard.controller.app.user.vo.*;
import cn.iocoder.yudao.module.handguard.convert.banner.BannerConvert;
import cn.iocoder.yudao.module.handguard.dal.dataobject.banner.BannerDO;
import cn.iocoder.yudao.module.handguard.service.user.MiniUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

/**
 * @author: liuweijun
 * @since: 2023/9/21 09:46
 * @description:
 */
@Tag(name = "小程序 - 用户额度")
@RestController
@RequestMapping("/mini/u/eval")
@Validated
public class UserEvaluationController {

    @Resource
    private MiniUserService miniUserService;


    @GetMapping("/my/limit")
    @Operation(summary = "查看我的额度")
    public CommonResult<Integer> getMyLimit() {
        //当前用户id
        Long userId = getLoginUser().getId();
        Integer count = miniUserService.getMyLimit(userId);
        return success(count);
    }

    @GetMapping("/my/test")
    @Operation(summary = "智能匹配-马上测额度")
    public CommonResult<MyTestResVo> getMyTest() {
        //当前用户id
        Long userId = getLoginUser().getId();
        MyTestResVo resVO = miniUserService.getMyTest(userId);
        return success(resVO);
    }



    @GetMapping("/my/optional/test")
    @Operation(summary = "手动选产品-马上测额度")
    @Parameter(name = "productId", description = "产品类型：\\n1.按揭房信贷(抵押贷)\\n2.保单贷(信贷)\\n3.个人贴息贷款(信贷)\\n4.工薪贷(信贷)\\n5.公积金贷(信贷)\\n6.企业贴息贷款(信贷)\\n7.全款车按揭车信贷(抵押贷)\\n8.商业商住楼写字楼厂房一抵押(抵押贷)\\n9.商业商住楼写字楼二次抵押(抵押贷)\\n10.商业写字楼按揭贷款(抵押贷)\\n11.税贷(信用贷)\\n12.企业流水贷(信用贷)\\n13.企业发票贷(信用贷)\\n14.住宅按揭贷款(抵押贷)\\n15.住宅抵押(抵押贷)\\n16.住宅二次抵押(抵押贷)\\n", required = true, example = "1024")
    public CommonResult<MyTestResVo> getMyOptionalTest(Long productId) {
        //当前用户id
        Long userId = getLoginUser().getId();
        MyTestResVo resVO = miniUserService.getMyOptionalTest(userId,productId);
        return success(resVO);
    }


    @PostMapping("/my/applyForProduct")
    @Operation(summary = "申请产品贷款")
    public CommonResult<ApplyForProductResVo> applyForProduct(@Valid @RequestBody ApplyForProductReqsVo reqsVo) {
        //当前用户id
        Long userId = getLoginUser().getId();
        reqsVo.setUserId(userId);
        ApplyForProductResVo res = miniUserService.applyForProduct(reqsVo);
        return success(res);
    }


    @PostMapping("/set/operator")
    @Operation(summary = "订单-设置业务员")
    public CommonResult<String> setOperator(@Valid @RequestBody SetOperatorVo req) {
        //当前用户id
        Long userId = getLoginUser().getId();
        String msg = miniUserService.setOperator(userId,req);
        return success(msg);
    }

}
